connect_error) { die("Connection failed: " . $conn->connect_error); } else { $sql = "SELECT * FROM timetable where date = \"".$date."\" and timetable = \"".$passedservice."\""; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { $tt_type=$row["timetable"]; $tt_longname=$row["timetable_name"]; } } else { $tt_type="No"; $tt_longname="No Heritage Service Today"; } } echo "

".$tt_longname ."

"; if ($tt_type != "No") { echo"

"; echo "
". $date." ".substr($time, 0, 5). "

"; //decide RUNS if ($passeddirection=="SOUTH") { echo "
Southbound Journeys
"; } if ($passeddirection=="NORTH") { echo "
Northbound Journeys
"; } if($passedfuture == "YES") { $pass_data="?date=".$date."&time=".$time."&direction=".$passeddirection; //find first run that we are interested in $firstrun=0; $sql = "SELECT * FROM timetablebase " ."where timetable=\"".$tt_type."\" " ."and direction=\"NORTH\" " ."and time >=\"".$time."\" " ."and time !=\"23:59\" " ."order by run,time"; $result = $conn->query($sql); if ($result->num_rows > 0) { $row = $result->fetch_assoc(); $firstrun=$row["run"]; } } else { $pass_data="?date=".$date."&time=".$time."&direction=".$passeddirection; //set first run, which should be first of the day $firstrun=1; } echo"
"; //now get last run $sql = "SELECT * FROM timetablebase where timetable = \"". $tt_type ."\" and direction= \"".$passeddirection."\" order by run desc"; $result = $conn->query($sql); $row = $result->fetch_assoc(); //find last run that we are interested in $lastrun=$row["run"]; //loop echo "
"; for ($firstrunonline=$firstrun;$firstrunonline<=$lastrun;$firstrunonline=$firstrunonline+3) { if ($passeddirection=="SOUTH") { $sql = "SELECT * FROM stop where ".$tt_type." != 0 order by ".$tt_type." desc"; } if ($passeddirection=="NORTH") { $sql = "SELECT * FROM stop where ".$tt_type." != 0 order by ".$tt_type.""; } $result = $conn->query($sql); if ($result->num_rows > 0) { // Allocation data here echo ""; echo ""; for ($allocshow=$firstrunonline;$allocshow<$firstrunonline+3;$allocshow++) { $sqlal = "SELECT * FROM timetablebase where run =\"".$allocshow."\" and direction= \"".$passeddirection."\" and timetable=\"".$tt_type."\" and stop=\"PIER\""; $resultal = $conn->query($sqlal); $rowal = $resultal->fetch_assoc(); if ($rowal["allocation"] != "") { $sqlal2 = "SELECT * FROM timetableallocation where ttdate =\"".$date."\" and ttalloc= \"".$rowal["allocation"]."\""; $resultal2 = $conn->query($sqlal2); $rowal2 = $resultal2->fetch_assoc(); if ($rowal2["tttram"] != "") { $tramnumber="
(".$rowal2["tttram"].")
"; } else { $tramnumber=""; } // Do links for allocation stuff // echo""; // No links in version below echo""; } } echo ""; // Allocation done while($row = $result->fetch_assoc()) { $outbuffer=""; $doshowthis = 0; // This links to stops // echo ""; // This next one doesn't if ($row["stop"]=="FLTW") { if ($passeddirection=="SOUTH") { $stopname=$row["stopname"]." Pharos St."; } else { $stopname=$row["stopname"]." Ferry"; } } else { $stopname=$row["stopname"]; } $outbuffer = $outbuffer . ""; // get next 3 runs $tmpruncount=$firstrunonline; $tmpruncount2=$firstrunonline+2; $sql2 = "SELECT * FROM timetablebase where direction= \"".$passeddirection."\" and stop=\"".$row["stop"]."\" and run>=\"".$tmpruncount."\" and run<=\"".$tmpruncount2."\" and timetable=\"".$tt_type."\" "; $result2 = $conn->query($sql2); if ($result2->num_rows > 0) { while($row2 = $result2->fetch_assoc()) { if ($row2["time"] == "23:59:00") { $outbuffer = $outbuffer . ""; } else { $outbuffer = $outbuffer . ""; $doshowthis=1; } } } $outbuffer = $outbuffer . ""; if ($doshowthis==1) { echo $outbuffer; } } // Via here echo ""; echo ""; for ($viashow=$firstrunonline;$viashow<$firstrunonline+3;$viashow++) { $sqlvia = "SELECT * FROM timetablebase where run =\"".$viashow."\" and direction= \"".$passeddirection."\" and timetable=\"".$tt_type."\" and stop=\"VIA\""; $resultvia = $conn->query($sqlvia); $rowvia = $resultvia->fetch_assoc(); echo""; if ($rowvia["destination"] == "TG") { $tg++;} if ($rowvia["destination"] == "LB") { $lb++;} } echo ""; // Via done echo ""; } } echo "
".$rowal["allocation"]."".$tramnumber."
".$rowal["allocation"].$tramnumber."
".$row["stopname"]."
".$stopname."
--:--
".substr($row2["time"], 0, 5)."
".$rowvia["destination"]."

"; } //vias if needed if ($tg>0) { echo "
TG - Operates via Thornton Gate
"; } if ($lb>0) { echo "
LB - Operates via Little Bispham
"; } //show shop tram if required. $sqlshop = "SELECT * FROM timetableallocation where ttdate =\"".$date."\" and ttalloc=\"S\" "; $resultshop = $conn->query($sqlshop); $rowshop = $resultshop->fetch_assoc(); if ($resultshop->num_rows >0 ) { echo "
Shop tram (".$rowshop[tttram].") ".$rowshop[misctext]."
"; } echo "
"; if ( $passeddirection=="NORTH" ) { echo "Southbound Trams"; } if ( $passeddirection=="SOUTH") { echo "Northbound Trams"; } echo "Select a day"; echo "
"; require("footer.php"); ?>